﻿
@echo off & setlocal EnableDelayedExpansion
echo Run StartServices.bat

title FSK-Django
call 'D:\Programe Files\Redis-x64-5.0.14\StartRedis.bat'

echo ping 1.1.1.1 -n 1 -w 3000 > nul

set obj[0]=8001
set port=0
set pid=0

for /f "usebackq delims== tokens=1-2" %%a in (`set obj`) do (
    set port=%%b
    for /f "tokens=5" %%m in ('netstat -aon ^| findstr ":%%b"') do (
        set pid=%%m
    )
    if "!pid!"=="0" (
        echo port [!port!] free!
    ) else (
        echo prot [!port!] killed!
        taskkill /pid !pid! /f /t
		taskkill /f /FI "FSK-Django"
    )
    set pid=0
)


D:\PycharmProjects\HS_DJ\venv\Scripts\python.exe -i run.py

echo start worki
exist